﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;


namespace Appsters
{
    public partial class Tasks : Form
    {
        public Tasks()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void button3_Click(object sender, EventArgs e)
        {
             this.WindowState = FormWindowState.Minimized;

        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            System.Reflection.Assembly myAssembly;
            myAssembly = System.Reflection.Assembly.GetExecutingAssembly();
            System.IO.Stream file;   
            Bitmap image;
            file = myAssembly.GetManifestResourceStream("Appsters.background.png");
            image = new Bitmap(file);
            this.BackgroundImage = image;

            save.Visible = true;
            clear.Visible = true;
            button9.Visible = true;
            button12.Visible = true;
            button7.Visible = true;
            button8.Visible = true;

            label1.Visible = true;
            label2.Visible = true;
            label3.Visible = true;
            label4.Visible = true;
            label5.Visible = true;

            comboBox1.Visible = true;
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            System.Reflection.Assembly myAssembly;
            myAssembly = System.Reflection.Assembly.GetExecutingAssembly();
            System.IO.Stream file;
            Bitmap image;

            file = myAssembly.GetManifestResourceStream("Appsters.background2.png");
            image = new Bitmap(file);
            this.BackgroundImage = image;

            save.Visible = false;
            clear.Visible = false;
            button9.Visible = false;
            button12.Visible = false;
            button7.Visible = false;
            button8.Visible = false;
            button10.Visible = false;
            button13.Visible = false;
            button6.Visible = false;
            button5.Visible = false;
            button11.Visible = false;
            button14.Visible = false;

            label1.Visible = false;
            label2.Visible = false;
            label3.Visible = false;
            label4.Visible = false;
            label5.Visible = false;

            comboBox1.Visible = false;
            comboBox2.Visible = false;

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void button5_Click(object sender, EventArgs e)
        {
            if (label4.Text == "0")
            {
                label4.Text = "0";
            }
            else
            {
                int n = Int32.Parse(label4.Text);
                n--;
                label4.Text = n.ToString();
            }
        }

        private void button6_Click(object sender, EventArgs e)
        {
            if (label4.Text == "9")
            {
                label4.Text = "9";
            }
            else
            {
                int n = Int32.Parse(label4.Text);
                n++;
                label4.Text = n.ToString();
            }
        }

        private void button7_Click(object sender, EventArgs e)
        {
            if (button11.Visible && button14.Visible)
            {
                button6.Visible = true;
                button5.Visible = true;
                button11.Visible = false;
                button14.Visible = false;
            }
            else if (button6.Visible && button5.Visible)
            {
                button10.Visible = true;
                button13.Visible = true;
                button5.Visible = false;
                button6.Visible = false;
            }
            else if (button10.Visible && button13.Visible)
            {
                button9.Visible = true;
                button12.Visible = true;
                button10.Visible = false;
                button13.Visible = false;
            }
            else
            {
                button11.Visible = true;
                button14.Visible = true;
                button9.Visible = false;
                button12.Visible = false;
            }
        }

        private void button9_Click(object sender, EventArgs e)
        {
            if (label1.Text == "12")
            {
                label1.Text = "12";
            }
            else
            { 
                //convert label to int then increment
                int n = Int32.Parse(label1.Text);
                n++;
                label1.Text = n.ToString();
            }
        }

        private void button10_Click(object sender, EventArgs e)
        {
            if (label3.Text == "5")
            {
                label3.Text = "5";
            }
            else
            {
                //convert label to int then increment
                int n = Int32.Parse(label3.Text);
                n++;
                label3.Text = n.ToString();
            }
        }

        private void button11_Click(object sender, EventArgs e)
        {
            if (label5.Text == "PM")
            {
                label5.Text = "AM";
            }
            else
            {
                label5.Text = "PM";
            }
        }

        private void button12_Click(object sender, EventArgs e)
        {
            if (label1.Text == "1")
            {
                label1.Text = "1";
            }
            else
            {
                //convert label to int then increment
                int n = Int32.Parse(label1.Text);
                n--;
                label1.Text = n.ToString();
            }
        }

        private void button13_Click(object sender, EventArgs e)
        {
            if (label3.Text == "0")
            {
                label3.Text = "0";
            }
            else
            {
                int n = Int32.Parse(label3.Text);
                n--;
                label3.Text = n.ToString();
            }
        }

        private void button14_Click(object sender, EventArgs e)
        {
            if (label5.Text == "PM")
            {
                label5.Text = "AM";
            }
            else
            {
                label5.Text = "PM";
            }
        }

        private void button8_Click(object sender, EventArgs e)
        {
            if (button9.Visible && button12.Visible)
            {
                button10.Visible = true;
                button13.Visible = true;
                button9.Visible = false;
                button12.Visible = false;
            }
            else if (button10.Visible && button13.Visible)
            {
                button6.Visible = true;
                button5.Visible = true;
                button10.Visible = false;
                button13.Visible = false;
            }
            else if (button5.Visible && button6.Visible)
            {
                button11.Visible = true;
                button14.Visible = true;
                button5.Visible = false;
                button6.Visible = false;
            }
            else
            {
                button9.Visible = true;
                button12.Visible = true;
                button11.Visible = false;
                button14.Visible = false;

            }
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox1.Text == "0")
            {
                comboBox2.Visible = true;
                label6.Visible = true;
            }
            else
            {
                comboBox2.Visible = true;
                label6.Visible = true;
            }
        }

        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            string t = title.Text;
            string s = subj.Text;
            string d = desc.Text;

            string docPath = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            string taskFolder = System.IO.Path.Combine(docPath, "Jotter\\Saved Files\\Tasks");
            System.IO.Directory.CreateDirectory(taskFolder);

            string path = System.IO.Path.Combine(taskFolder, t + ".txt");

            System.IO.File.WriteAllText(path, t + "\t" + s + "\t" + d);
        }

        private void backButton_Click(object sender, EventArgs e)
        {
            DailyView dv = new DailyView();
            dv.Show();
            this.Hide();
        }
    }
}
